-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Enabling Annotations in Responses #3698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enabling Annotations in Responses #3698
Conversation
Signed-off-by: Francisco Javier Arceo <[email protected]>
5ac80d4
to
adf47bd
Compare
Signed-off-by: Francisco Javier Arceo <[email protected]>
adf47bd
to
eb8acd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, some minor nits
citation_instruction = "" | ||
if unique_files: | ||
citation_instruction = " Cite sources immediately at the end of sentences before punctuation, using `<|file-id|>` format (e.g., 'This is a fact <|file-Cn3MSNn72ENTiiq11Qda4A|>.')." | ||
citation_instruction += ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why break this up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a stylistic preference but i can collapse it 👍
) | ||
|
||
# handling missing attributes for old versions | ||
citation_files = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be written a bit more simply if not using a comprehension or if you want to use the comprehension define a small local function maybe. it's hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated 👍
Signed-off-by: Francisco Javier Arceo <[email protected]>
What does this PR do?
Implements annotations for
file_search
tool.Also adds some logs and tests.
How does this work?
<|file-id|>
tokens during generation with instructions from search resultsAnnotationFileCitation
objectsExample
This is the updated
quickstart.py
script, which uses theextra_body
to register the embedding model.Example of the full response
The relevant output looks like this:
And the code below outputs only periods highlighting that the position/index behaves as expected—i.e., the annotation happens at the end of the sentence.
Test Plan
Unit tests added.